<template>
  <div class="part">
    <div class="filter">
      <el-form :model="query" inline>
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="开始日期">
              <el-date-picker
                v-model="query.start_time"
                size="mini"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="日期">
              <el-date-picker
                v-model="query.end_time"
                size="mini"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="查询">
              <el-button size="mini" icon="el-icon-refresh-right" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <el-table :data="part_list">
      <el-table-column label="日期" prop="date" />
      <el-table-column label="备品备件" prop="part" />
      <el-table-column label="工单" prop="wordorder" />
      <el-table-column label="出库数量" prop="appear_number" />
      <el-table-column label="单价 (¥)" prop="price" />
      <el-table-column label="总价 (¥)" prop="total_price" />
    </el-table>
  </div>
</template>

<script>
import API from '../../../api/maintain/part'
export default {
  name: 'EquipmentPart',
  props: {
    value: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      query: {},
      part_list: [
        {
          date: '2020-01-01',
          part: '机油',
          wordorder: 'ORDER1',
          appear_number: '10',
          price: '30',
          total_price: '300'
        }
      ]
    }
  },
  watch: {
    value() {
      this.index()
    }
  },
  created() {
    this.index()
  },
  methods: {
    index() {
      API.index({ equipment_id: this.value }).then(response => {
        this.list = response.data.data
      })
    }
  }
}
</script>
